home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Gfx / Edit / TSMorph / rexx / Preview.TSM < prev    next >
Text File  |  1995-02-05  |  5KB  |  113 lines

  1. /* example Preview script file for TSMorph        */
  2. /* This example renders the frame as a 16 colour  */
  3. /* grey scale image, with a resolution of ~128x64 */
  4. /* using the T: directory as a work directory     */
  5. /* and then displays the image                    */
  6. /* $VER: Preview_TSM 3.1 (5.2.95)
  7.  */
  8.  
  9. /* get arguments                                  */
  10. parse arg Frame " " FileName
  11.  
  12. /* Frame    - current frame number                */
  13. /* FileName - Filename of points file             */
  14. /*                                                */
  15. /* current Settings have previously been saved in */
  16. /* 'T:TSMorph.prefs'                              */
  17.  
  18.  
  19. /* make rexx the default command host             */
  20. address "REXX"
  21. /* add rexxsupport.library if not already present */
  22. /* (required for next()                           */
  23. if ~(show('L','rexxsupport.library')) then
  24.    call addlib('rexxsupport.library',0,-30,0)
  25. /* open input file                                */
  26. if open('infile',FileName,'r') then do
  27.    /* open output file                            */
  28.    if open('outfile','T:TSM.points','w') then do
  29.       /* read possible header                     */
  30.       line = readln('infile')
  31.       /* write header                             */
  32.       call writeln('outfile','TSMorph 1.2')
  33.       if (line = 'TSMorph 1.2') then
  34.          /* read over header                      */
  35.          line = readln('infile')
  36.       /* read and write input file names          */
  37.       call writeln('outfile',line)
  38.       call writeln('outfile',readln('infile'))
  39.       call writeln('outfile',readln('infile'))
  40.       call writeln('outfile',readln('infile'))
  41.       /* read output name                         */
  42.       call readln('infile')
  43.       /* write our output file name               */
  44.       call writeln('outfile','T:TSM.pic')
  45.       /* read and write details                   */
  46.       line = readln('infile')
  47.       parse var line "w=" width ",h=" height ",Frames=" frames ",Single=" single ",Start=" start
  48.       call writeln('outfile',line)
  49.       /* copy rest of file                        */
  50.       do while ~(eof('infile'))
  51.          call writeln('outfile',readln('infile'))
  52.       end
  53.       /* close output file                        */
  54.       call close('outfile')
  55.       /* calculate dx and dy parameters           */
  56.       /* image is then 128x64 minimum resolution  */
  57.       if (width > 128) then
  58.          dx = trunc((width - 128) / 128)
  59.       else
  60.          dx = 0
  61.       if (height > 64) then
  62.          dy = trunc((height - 64) / 64)
  63.       else
  64.          dy = 0
  65.       /* copy points for anim warps/morphs        */
  66.       if (single = 2) | (single = 3) then
  67.          if (Frame < 10) then
  68.             address command 'copy "'FileName'.00'Frame'" T:TSM.points.00'Frame
  69.          else
  70.             if (Frame < 100) then
  71.                address command 'copy "'FileName'.0'Frame'" T:TSM.points.0'Frame
  72.             else
  73.                address command 'copy "'FileName'.'Frame'" T:TSM.points.'Frame
  74.       /* Write Prescript                          */
  75.       /* This only renders the requested frame    */
  76.       if open('pre','T:Prescript.TSM','w') then do
  77.          /* Heading comment                       */
  78.          call writeln('pre','/* Preview Prescript */')
  79.          /* get arguments                         */
  80.          call writeln('pre','parse arg Base')
  81.          /* get frame number, from 1              */
  82.          /* see Prescript.TSM for more info       */
  83.          call writeln('pre','f = C2D(IMPORT(D2C(STRIP(Base),4),4),4)')
  84.          /* get start frame number                */
  85.          call writeln('pre','s = C2D(IMPORT(D2C(STRIP(Base)+76,4),4),4)')
  86.          /* if it is not our frame then           */
  87.          call writeln('pre','if ~((f+s-1) = 'Frame') then')
  88.          /* do not produce this frame             */
  89.          /* see Prescript.TSM for more info       */
  90.          call writeln('pre','   call EXPORT(D2C(STRIP(Base)+40,4),D2C(0,4),4)')
  91.          /* stop                                  */
  92.          call writeln('pre','exit')
  93.          /* close prescript file                  */
  94.          call close('pre')
  95.          /* call TSMorph-render to render frame   */
  96.          /* this saves BW16 image                 */
  97.          address command 'TSMorph:TSMorph-render INTEGER=YES FILES=T:TSM.points POSTSCRIPT=OFF CREATEICONSR=NO ANTIALIAS=NO DX='dx' DY='dy' PRESCRIPT=T:Prescript SAVEFORMAT=BW16 SETTINGS=T:TSMorph.prefs'
  98.          /* check OS version and then             */
  99.          /* display image using relevant command  */
  100.          execbase = c2d(NEXT('00000004'x))
  101.          version = c2d(IMPORT(d2c(execbase+20,4),4))/65536
  102.          if (version < 39) then
  103.             address command 'sys:utilities/Display T:TSM.pic'
  104.          else
  105.             address command 'sys:utilities/MultiView T:TSM.pic SCREEN'
  106.       end
  107.    end
  108.    /* close input file                            */
  109.    call close('infile')
  110. end
  111. /* the end!                                       */
  112. exit
  113.